﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WorkingTitleDungeonCrawler
{
    class Monster : MovingGameObj
    {

        // Constructor
        public Monster()
        {
            MaxSpeed = 20F;
            ShotPower = 0;
            Life = 100F;
            Angle = (float)(Math.PI / 2);
        }



        // Properties
        public float MaxSpeed { get; set; }
        public float ShotPower { get; set; }
        public int WeaponType { get; set; }
        public bool ShotFired { get; set; }
        public float Life { get; set; }
        public int Frame { get; set; }
        public float timer { get; set; }
        public float TIMER { get; set; }

        // Methods
        public override void Update(GameTime gameTime)
        {
            //float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            //timer -= elapsed;
            Random r = new Random();
            int randomNumber = r.Next(0, 20);

            switch (randomNumber)
            {

                case 0:

                    Frame = 1;
                    Speed = MaxSpeed;
                    Angle = -(float)(Math.PI / 2);
                    break;
            
                case 1:

                    Frame = 0;
                    Speed = MaxSpeed;
                    Angle = (float)(Math.PI / 2);
                    break;

                case 2:

                    Frame = 2;
                    Speed = MaxSpeed;
                    Angle = (float)(Math.PI);
                    break;

                case 3:

                    Frame = 3;
                    Speed = MaxSpeed;
                    Angle = (float)(2 * Math.PI);
                    break;

                default:
            
                    Speed = MaxSpeed;
                    break;
            }

            Direction = new Vector2((float)(Math.Cos(Angle)), (float)(Math.Sin(Angle)));

            base.Update(gameTime);

            
        }

        public override void Draw(SpriteBatch spritebatch, Vector2 DrawOffset)
        {
           Rectangle tmp = new Rectangle((Frame % 1) * 48, Frame * 48, 48, 48);

            spritebatch.Draw(Gfx, Position - DrawOffset + new Vector2(475, 300), tmp,
                     Color.White, 0, new Vector2(Gfx.Height / 2, Gfx.Width / 2), 1.0F,
                     SpriteEffects.None, 0);
        }
    }
}
